package WaiBao;

import java.util.Arrays;

public class ZhangYin {
    public static void main(String[] args) {
        String[] name = {"赵四(班长)","王大炮(体育委员)", "小李(学习委员)","李大伟(文艺委员)", "萧敬腾", "李贺", "李白", "李子园", "王大崔", "李天东", "王子阳", "唐嫣",
                "鹿晗", "黄子韬", "张艺兴", "五月天", "吴奇隆", "郭富城", "周润发", "梁朝伟", "张家辉", "景甜", "王子文", "杨颖", "孙俪", "邓超", "李晨", "周星驰",
                "欧豪", "张瑛(学生)"};//考生本人: 张瑛(学生)
        int[] age = {19, 21, 20, 19, 18, 20, 19, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 18, 18, 20};//考生本人年龄:20
        double[] V1 = {77, 92, 84, 90, 77, 69, 78, 89, 80, 80, 91, 87, 85, 88, 65, 68, 99, 99, 96, 88, 92, 91, 95, 65, 75, 74, 94, 74, 88, 93};
        double[] V2 = {95, 75, 89, 76, 98, 77, 68, 69, 90, 70, 91, 77, 86, 95, 65, 65, 76, 99, 66, 98, 72, 71, 95, 86, 75, 88, 84, 64, 80, 94};
        double[] V3 = {81, 76, 84, 75, 77, 66, 71, 66, 80, 70, 93, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 71, 89, 94};

        double H ;//代表每个学生的总分
        double K;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            H = V1[i] + V2[i] + V3[i];
//            K= (H * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + H);
//            System.out.println(name[i] + "的平均分为:" + K);
//        }

        double O = 0, P = 0;
        double[] shuchu = new double[30];
//        for (int i = 0; i < 30; i++) {
//            O = V1[i] + V2[i] + V3[i];
//            P= (O * 1.0) / 3;
//            shuchu[i] = O;
//        }
//
//        for (int i = 0; i <shuchu.length - 1; i++) {
//            for (int j = 0; j < shuchu.length - i - 1; j++) {
//                if (shuchu[j] < shuchu[j + 1]) {
//                    double tep = shuchu[j];
//                    shuchu[j] = shuchu[j + 1];
//                    shuchu[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(shuchu[i]);
//        }



        double Y1 = 0, Y2 = 0, Y3 = 0;//计算每门课的平均分
        double T1 = 0, T2 = 0, T3 = 0;//计算每门课标准差
        double L1 = 0, L2 = 0, L3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < V1.length; i++) {
            he += V1[i];
        }
        Y1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" +Y1);
        double Sum = 0;
        for (int i = 0; i < V2.length; i++) {
            Sum += V2[i];
        }
        Y2 = (Sum * 1.0) / 30;
        System.out.println("微生物学的班级平均分为:" + Y2);
        double sum = 0;
        for (int i = 0; i < V3.length; i++) {
            sum += V3[i];
        }
        Y3 = (sum * 1.0) / 30;
        System.out.println("人体组织解剖学的班级平均分为:" + Y3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < V1.length; i++) {
            c1 += (V1[i] - Y1) * (V1[i] - Y1);
        }
        T1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + T1);
        for (int i = 0; i < V2.length; i++) {
            c2 += (V2[i] - Y2) * (V2[i] - Y2);
        }
        T2 = Math.sqrt(c2*1.0/30);
        System.out.println("微生物学的班级标准差为:" + T2);

        for (int i = 0; i < V3.length; i++) {
            c3 += (V3[i] - Y3) * (V3[i] - Y3);
        }
        T3 = Math.sqrt(c3*1.0/30);
        System.out.println("人体组织解剖学的班级标准差为:" + T3);
//


        Arrays.sort(V1);
        Arrays.sort(V2);
        Arrays.sort(V3);
        L1 = (V1[15] + V2[16]) * 1.0 / 2;
        L2 = (V2[15] + V2[16]) * 1.0 / 2;
        L3 = (V3[15] + V3[16]) * 1.0 / 2;
        System.out.println("生物化学的中位数为:" + L1);
        System.out.println("微生物学的中位数为:" + L2);
        System.out.println("人体组织解剖学的中位数为:" + L3);

    }
}
